* Interpreting trends in intergenerational mobility
* Martin Nybom and Jan Stuhler
* Master do-file PSID application
* December 2023

ssc install outtable

clear all
set more off, permanently
set maxvar 20000
global userpath "/Users/martinnybom/Dropbox/PSID/PSID"
global rawdata "${userpath}/PSID_codes_clean/Raw"
global path "${userpath}/PSID_codes_clean"

cd "${path}"
cap mkdir Log
cap mkdir Data

* Prepare and save raw data

* Individual-level data

cd "${rawdata}/ind2017er"
do IND2017ER.do
compress
save "${path}/Data/PSID_individual_raw_data.dta" , replace

* Household-level data

cd "${path}"
do "${path}/Do/family_files.do"

* Intergenerational links

cd "${path}"
do "${path}/Do/fim10243_gid_BA_2_BAL_wide.do"

/* Sample setup and main analysis */

* Load programs
do "${path}/Do/programs.do"

* Individuals
do "${path}/Do/sons_data.do"
do "${path}/Do/dads_data.do"
do "${path}/Do/moms_data.do"

* Collapse parent files
do "${path}/Do/sons_data_clean.do"
do "${path}/Do/dads_data_clean.do"
do "${path}/Do/moms_data_clean.do"

* Analysis
do "${path}/Do/analysis.do"
